package com.doit.mr.day06.yarn;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * @DATE 2021/12/7/17:07
 * @Author MDK
 * @Version 2021.2.2
 **/
public class Driver {
    public static void main(String[] args) throws Exception{
        System.setProperty("HADOOP_USER_NAME","root");
        Configuration conf = new Configuration();
        //设置提交的运行模式  默认本地
        conf.set("mapreduce.framework.name","yarn");
        //yarn主节点位置
        conf.set("yarn.resourcemanager.hostname","linux01");
        //跨平台参数
        conf.set("mapreduce.app-submission.cross-platform","true");
        //创建job
        Job job = Job.getInstance(conf, "wordCount");
        //设置自己的jar包
        job.setJar("d://wc.jar");
        //设置Mapper类,Reducer类及输出数据类型
        job.setMapperClass(WordCountMapper.class);
        job.setReducerClass(WordCountReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        //设置路径,提交job
        FileInputFormat.setInputPaths(job, new Path("/data/wc/"));
        FileOutputFormat.setOutputPath(job, new Path("/data/wc_res"));
        job.waitForCompletion(true);
    }
}
